import request from '@/utils/request'
import axios from 'axios'

/**
 * 设置题目
 * @param parameter
 * @returns {*}
 */
export function setTopic(parameter) {
  return request({
    url: '/topic/setting',
    method: 'post',
    data: parameter
  })
}


export function getAuthorTopicList(parameter) {
  return request({
    url: '/topic/list/author',
    method: 'get',
    params: parameter
  })
}


/**
 * 修改我设置的题目
 * @param parameter
 * @returns {*}
 */
export function updateMySetTopic(parameter) {
  return request({
    url: '/topic/update',
    method: 'put',
    data: parameter
  })
}

/**
 * 删除我设置的题目
 * @param parameter
 * @returns {*}
 */
export function delMySetTopic(parameter) {
  return request({
    url: `/topic/del?topicId=${parameter}`,
    method: 'delete'
  })
}

export function getSubList(parameter) {
  return request({
    url: '/judge/subInfo',
    method: 'get',
    params: parameter
  })
}

export function getTopicOrderUseInfo() {
  return request({
    url: '/topic/orderList',
    method: 'get'
  })
}

export function getRecycleBin(parameter) {
  return request({
    url: '/topic/list/author/recycleBin',
    method: 'get',
    params: parameter
  })
}

export function deletePermanent(topicId) {
  return request({
    url: '/topic/permanentDelete',
    method: 'delete',
    params: {
      topicId
    }
  })
}

export function recycleSubject(order, topicId) {
  return request({
    url: '/topic/recover',
    method: 'post',
    data: {
      order,
      topicId
    }
  })
}

export function getQuestionBank(curPath) {
  return request({
    url: '/topic/questionBank/list',
    method: 'get',
    params: {
      curPath
    }
  })
}

export function makeFolder(dirName, curPath) {
  return request({
    url: '/topic/questionBank/addFolder',
    method: 'post',
    params: {
      dirName,
      curPath
    }
  })
}

export function delDirOrFiles(fileNames) {
  console.log(fileNames)
  return request({
    url: '/topic/questionBank/delFiles',
    method: 'post',
    data: {
      fileNames
    }
  })
}